import type { Module, ActionContext } from 'vuex'
import type { AxiosResponse } from 'axios'
import type { baseStateType } from './typings'
import {
  getBasestationList,
  getBasestationRemove,
  basestationExport,
  importBasestationPostExcel,
  basestationAdd,
  basestationUpdate,
  basestationView,
  getBasebuildList,
  getBasebuildRemove,
  basebuildExport,
  importBasebuildPostExcel,
  importBasebuildPostExcelUpdate,
  basebuildAdd,
  basebuildUpdate,
  basebuildView,
  basestationGetAreaName,
  setLampPostScope,
  getLampPostScope,
  getLampPostByscope,
  getLampPostById,
  getBatchTotalResult,
  getBasebuildbatchTotalList,
  importBasebuildPostExcelResult,
  exportBatchExport,
  getBasebuildbatchTotal,
  getBasebuildbatchBatchList,
  getBasebuildbatchAddDelisting,
  getBasebuildbatchAddBuildDelisting,
  getBasebuildbatchTotalInfo,
  getBasebuildbatchBatchMatchList,
  getBasebuildbatchDistingList,
  getBasebuildbatchSetDelistingTime,
  getBasebuildbatchRemoveDelisting,
  getBasebuildbatchUpdateDelisting,
  basebuildbatchExport,
  importBasebuildbatch,
  getCabinetList,
  getCabinetRemove,
  importCabinet,
  exportCabinet,
  getCabinetAdd,
  getCabinetUpdate,
  getCabinetView,
  getElectricityList,
  getElectricityRemove,
  importeEectricity,
  exportElectricity,
  getElectricityAdd,
  getElectricityUpdate,
  getElectricityView,
  getElectricitySelectListCode,
  getBaseBuildHistroy,
  getSelectBatchNumListBox,
  getListBusinessLogByUser,
  getWorkAreaList
} from '~/api/base'
import {
  getAssetHomeOptionsBar,
  getAssetHomeMapSpecialTenant
} from '~/api/assetManagement/assetHome'
import { getDataDictionaryByCode } from '~/api/global'
import { DownloadAttachment } from '~/utils/util'

const base: Module<baseStateType, baseStateType> = {
  namespaced: true,
  state: {
    //  是否共享
    shareOpt: [],
    //  基站状态
    baseStatusOpt: [],
    //  运营商
    operatorOpt: [],
    //  站点类型
    siteTypeOpt: [],
    //  是否匹配
    isMatchOpt: [],
    //  地区名称
    regionNameOpt: [],
    //  查勘状态
    surveyStatusOpt: [],
    //  建设类型
    buildOpt: [],
    //  去重
    duplicateOpt: [
      { dictKey: 1, dictValue: '去重' },
      { dictKey: 0, dictValue: '不去重' }
    ],
    //  需求类型
    demandTypeOpt: [],
    //  机柜-使用状态
    usageStatusOpt: [],
    //  电表-使用状态
    electricityUsageStatusOpt: []
  },
  getters: {
    shareOpt: (state) => state.shareOpt,
    baseStatusOpt: (state) => state.baseStatusOpt,
    operatorOpt: (state) => state.operatorOpt,
    siteTypeOpt: (state) => state.siteTypeOpt,
    isMatchOpt: (state) => state.isMatchOpt,
    regionNameOpt: (state) => state.regionNameOpt,
    surveyStatusOpt: (state) => state.surveyStatusOpt,
    duplicateOpt: (state) => state.duplicateOpt,
    buildOpt: (state) => state.buildOpt,
    demandTypeOpt: (state) => state.demandTypeOpt,
    usageStatusOpt: (state) => state.usageStatusOpt,
    electricityUsageStatusOpt: (state) => state.electricityUsageStatusOpt
  },
  mutations: {
    SURVEY_TYPE_GET(state, payload) {
      state.surveyStatusOpt = payload
    },
    BASE_STATUS_GET(state, payload) {
      state.baseStatusOpt = payload
    },
    OPERATOR_GET(state, payload) {
      state.operatorOpt = payload
    },
    SHARE_GET(state, payload) {
      state.shareOpt = payload
    },
    IS_MATCH_GET(state, payload) {
      state.isMatchOpt = payload
    },
    SITE_TYPE_GET(state, payload) {
      state.siteTypeOpt = payload
    },
    REGION_NAME_GET(state, payload) {
      state.regionNameOpt = payload
    },
    BUILD_GET(state, payload) {
      state.buildOpt = payload
    },
    DEMAND_TYPE_GET(state, payload) {
      state.demandTypeOpt = payload
    },
    CABINET_USE_STATUS(state, payload) {
      state.usageStatusOpt = payload
    },
    ELECTRICITY_STATUS(state, payload) {
      state.electricityUsageStatusOpt = payload
    }
  },
  actions: {
    // 查询租户专题图的资产组件图标(按钮操作栏)
    async GetAssetHomeOptionsBar() {
      return await getAssetHomeOptionsBar({ specialCode: 'basestation_home' }).then(
        (res: AxiosResponse) => res?.data
      )
    },
    // 查询资产首页地图所需加载的租户配置的专题图数据
    async GetAssetHomeMapSpecialTenant() {
      return await getAssetHomeMapSpecialTenant({ specialCode: 'basestation_home' }).then(
        (res: AxiosResponse) => res?.data
      )
    },
    //  根据关键字搜索地区
    BasestationGetAreaName<S, T>({ commit }: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        basestationGetAreaName<T>(params)
          .then((res: AxiosResponse) => {
            const arr: { dictKey: number; dictValue: string }[] = []
            res?.data?.data.forEach((element: string, index: number) => {
              arr.push({
                dictKey: index,
                dictValue: element
              })
            })
            commit('REGION_NAME_GET', arr || [])
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  查勘状态
    SurveyStatusGet<S, T>({ commit }: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getDataDictionaryByCode<T>(params)
          .then((res: AxiosResponse) => {
            commit('SURVEY_TYPE_GET', res?.data?.data || [])
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  站点类型
    SiteTypeGet<S, T>({ commit }: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getDataDictionaryByCode<T>(params)
          .then((res: AxiosResponse) => {
            commit('SITE_TYPE_GET', res?.data?.data || [])
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  是否匹配
    IsMatchGet<S, T>({ commit }: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getDataDictionaryByCode<T>(params)
          .then((res: AxiosResponse) => {
            commit('IS_MATCH_GET', res?.data?.data || [])
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  基站状态
    BaseStatusGet<S, T>({ commit }: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getDataDictionaryByCode<T>(params)
          .then((res: AxiosResponse) => {
            commit('BASE_STATUS_GET', res?.data?.data || [])
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  运营商
    OperatorGet<S, T>({ commit }: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getDataDictionaryByCode<T>(params)
          .then((res: AxiosResponse) => {
            commit('OPERATOR_GET', res?.data?.data || [])
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  是否共享
    ShareGet<S, T>({ commit }: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getDataDictionaryByCode<T>(params)
          .then((res: AxiosResponse) => {
            commit('SHARE_GET', res?.data?.data || [])
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  建设类型
    BuildGet<S, T>({ commit }: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getDataDictionaryByCode<T>(params)
          .then((res: AxiosResponse) => {
            commit('BUILD_GET', res?.data?.data || [])
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  需求类型
    DemandTypeGet<S, T>({ commit }: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getDataDictionaryByCode<T>(params)
          .then((res: AxiosResponse) => {
            commit('DEMAND_TYPE_GET', res?.data?.data || [])
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  机柜-使用状态 asset_cabinet_use_status
    CabinetUseStatus<S, T>({ commit }: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getDataDictionaryByCode<T>(params)
          .then((res: AxiosResponse) => {
            commit('CABINET_USE_STATUS', res?.data?.data || [])
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  电表-使用状态 asset_electricity_status
    ElectricityStatus<S, T>({ commit }: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getDataDictionaryByCode<T>(params)
          .then((res: AxiosResponse) => {
            commit('ELECTRICITY_STATUS', res?.data?.data || [])
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  资产数据-列表
    GetBasestationList<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBasestationList<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  资产数据-删除
    GetBasestationRemove<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBasestationRemove<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    // 资产数据-导出
    async DasestationExport<S, T>(_: ActionContext<S, T>, params: T) {
      return await basestationExport<T>(params).then((res: AxiosResponse) => {
        const contentDisposition = res?.headers?.['content-disposition']
        if (contentDisposition && res.data) {
          DownloadAttachment(decodeURI(contentDisposition.substring(20)), res.data)
        }
        return res.data
      })
    },
    // 资产数据-导入
    async ImportBasestationPostExcel<S, T>(_: ActionContext<S, T>, params: T) {
      return await importBasestationPostExcel<T>(params).then((res: AxiosResponse) => res?.data)
    },
    //  资产数据-新增
    BasestationAdd<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        basestationAdd<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  资产数据-编辑
    BasestationUpdate<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        basestationUpdate<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  资产数据-详情
    BasestationView<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        basestationView<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  基站规划-列表
    GetBasebuildList<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBasebuildList<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  基站规划-删除
    GetBasebuildRemove<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBasebuildRemove<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    // 基站规划-导出
    async BasebuildExport<S, T>(_: ActionContext<S, T>, params: T) {
      return await basebuildExport<T>(params).then((res: AxiosResponse) => {
        const contentDisposition = res?.headers?.['content-disposition']
        if (contentDisposition && res.data) {
          DownloadAttachment(decodeURI(contentDisposition.substring(20)), res.data)
        }
        return res.data
      })
    },
    // 基站规划-导入
    async ImportBasebuildPostExcel<S, T>(_: ActionContext<S, T>, params: T) {
      return await importBasebuildPostExcel<T>(params).then((res: AxiosResponse) => res?.data)
    },
    // 基站规划-导入-更新
    async ImportBasebuildPostExcelUpdate<S, T>(_: ActionContext<S, T>, params: T) {
      return await importBasebuildPostExcelUpdate<T>(params).then((res: AxiosResponse) => res?.data)
    },
    //  基站规划-新增
    BasebuildAdd<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        basebuildAdd<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  基站规划-编辑
    BasebuildUpdate<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        basebuildUpdate<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  基站规划-详情
    BasebuildView<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        basebuildView<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  设置灯杆范围
    SetLampPostScope<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        setLampPostScope<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  获取灯杆范围
    GetLampPostScope<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getLampPostScope<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  周边灯杆
    GetLampPostByscope<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getLampPostByscope<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  周边灯杆详情
    GetLampPostById<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getLampPostById<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  需求批次统计结果
    GetBatchTotalResult<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBatchTotalResult<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  摘牌库管理
    GetBasebuildbatchTotalList<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBasebuildbatchTotalList<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  特批详情
    GetBasebuildbatchTotalInfo<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBasebuildbatchTotalInfo<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    // 基站规划-导入摘牌结果
    async ImportBasebuildPostExcelResult<S, T>(_: ActionContext<S, T>, params: T) {
      return await importBasebuildPostExcelResult<T>(params).then((res: AxiosResponse) => res?.data)
    },
    // 基站规划-导出需求批次筛选数据
    async ExportBatchExport<S, T>(_: ActionContext<S, T>, params: T) {
      return await exportBatchExport<T>(params).then((res: AxiosResponse) => {
        const contentDisposition = res?.headers?.['content-disposition']
        if (contentDisposition && res.data) {
          DownloadAttachment(decodeURI(contentDisposition.substring(20)), res.data)
        }
        return res.data
      })
    },
    //  站址查勘-批次分析
    GetBasebuildbatchTotal<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBasebuildbatchTotal<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  站址查勘-需求批次列表搜索
    GetBasebuildbatchBatchList<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBasebuildbatchBatchList<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  站址查勘-加入摘牌库
    GetBasebuildbatchAddDelisting<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBasebuildbatchAddDelisting<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  站址查勘-加入摘牌库
    GetBasebuildbatchAddBuildDelisting<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBasebuildbatchAddBuildDelisting<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  摘牌库管理-需求匹配列表搜索
    GetBasebuildbatchBatchMatchList<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBasebuildbatchBatchMatchList<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  摘牌库管理-需求匹配列表搜索
    GetBasebuildbatchDistingList<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBasebuildbatchDistingList<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  摘牌库管理-更新摘牌时间
    GetBasebuildbatchSetDelistingTime<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBasebuildbatchSetDelistingTime<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  摘牌库管理-移出摘牌库
    GetBasebuildbatchRemoveDelisting<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBasebuildbatchRemoveDelisting<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  摘牌库管理-更新批次折扣数据
    GetBasebuildbatchUpdateDelisting<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBasebuildbatchUpdateDelisting<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    // 摘牌库管理-导出
    async BasebuildbatchExport<S, T>(_: ActionContext<S, T>, params: T) {
      return await basebuildbatchExport<T>(params).then((res: AxiosResponse) => {
        const contentDisposition = res?.headers?.['content-disposition']
        if (contentDisposition && res.data) {
          DownloadAttachment(decodeURI(contentDisposition.substring(20)), res.data)
        }
        return res.data
      })
    },
    // 导入摘牌结果
    async ImportBasebuildbatch<S, T>(_: ActionContext<S, T>, params: T) {
      return await importBasebuildbatch<T>(params).then((res: AxiosResponse) => res?.data)
    },
    // 机柜管理-列表
    GetCabinetList<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getCabinetList<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  机柜管理-删除
    GetCabinetRemove<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getCabinetRemove<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    // 机柜管理-导入
    async ImportCabinet<S, T>(_: ActionContext<S, T>, params: T) {
      return await importCabinet<T>(params).then((res: AxiosResponse) => res?.data)
    },
    // 机柜管理-导出
    async ExportCabinet<S, T>(_: ActionContext<S, T>, params: T) {
      return await exportCabinet<T>(params).then((res: AxiosResponse) => {
        const contentDisposition = res?.headers?.['content-disposition']
        if (contentDisposition && res.data) {
          DownloadAttachment(decodeURI(contentDisposition.substring(20)), res.data)
        }
        return res.data
      })
    },
    //  机柜管理-新增
    GetCabinetAdd<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getCabinetAdd<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  机柜管理-编辑
    GetCabinetUpdate<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getCabinetUpdate<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  机柜管理-详情
    GetCabinetView<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getCabinetView<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    // 电表管理-列表
    GetElectricityList<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getElectricityList<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  电表管理-删除
    GetElectricityRemove<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getElectricityRemove<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    // 电表管理-导入
    async ImporteEectricity<S, T>(_: ActionContext<S, T>, params: T) {
      return await importeEectricity<T>(params).then((res: AxiosResponse) => res?.data)
    },
    // 电表管理-导出
    async ExportElectricity<S, T>(_: ActionContext<S, T>, params: T) {
      return await exportElectricity<T>(params).then((res: AxiosResponse) => {
        const contentDisposition = res?.headers?.['content-disposition']
        if (contentDisposition && res.data) {
          DownloadAttachment(decodeURI(contentDisposition.substring(20)), res.data)
        }
        return res.data
      })
    },
    //  电表管理-新增
    GetElectricityAdd<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getElectricityAdd<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  电表管理-编辑
    GetElectricityUpdate<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getElectricityUpdate<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  电表管理-详情
    GetElectricityView<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getElectricityView<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  电表管理-根据code查询关联匹配
    GetElectricitySelectListCode<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getElectricitySelectListCode<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  站址查勘-查勘时光机历史接口
    GetBaseBuildHistroy<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getBaseBuildHistroy<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  站址查勘-批次关键字查询下拉框
    GetSelectBatchNumListBox<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getSelectBatchNumListBox<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  站址查勘-批次关键字查询下拉框
    GetListBusinessLogByUser<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getListBusinessLogByUser<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    },
    //  资产分布-工区数据
    GetWorkAreaList<S, T>(_: ActionContext<S, T>, params: T) {
      return new Promise((resolve, reject) => {
        getWorkAreaList<T>(params)
          .then((res: AxiosResponse) => {
            resolve(res.data)
          })
          .catch((err: AxiosResponse) => {
            reject(err)
          })
      })
    }
  }
}

export default base
